package http_client

import (
	"context"
	"git.myscrm.cn/golang/stark/v4"
	"github.com/parnurzeal/gorequest"
)

const (
	TENANT_CONFIG_API_HOST = "tenant_config_api_host"
)

type TenantConfigClient struct {
	client *HttpClientTool
}

// NewTenantConfigClient
// 供方SaaS多租户配置 client工具类
func NewTenantConfigClient() *TenantConfigClient {
	return &TenantConfigClient{
		client: New(),
	}
}

// Get
// 多租户get请求
func (c *TenantConfigClient) Get(ctx context.Context, path string, params map[string]interface{}) *TenantConfigClient {
	url := stark.Configer.(stark.ApolloConfigerIface).GetStringValue(TENANT_CONFIG_API_HOST, "") + path
	url = JoinQueryStr(url, params)

	c.client = c.client.Get(ctx, url, nil)
	return c
}

// EndStruct
// convert interface(v) to struct
func (c *TenantConfigClient) EndStruct(v interface{}) (gorequest.Response, []byte, []error) {
	return c.client.EndStruct(v)
}
